import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import { Button, Text } from 'native-base';
import { Actions } from 'react-native-router-flux';
import { connect } from 'react-redux';
import { increase, decrease, fetchList,addToCart } from '../actions';

const mapStateToProps = state => {
  console.log("mapStateToProps",state)
  return {
    counter: state.counter.counter
  };
};

 class HomeScene extends Component {
  render() {
    console.log("HomeScene",this.props)
    const { counter, decrease } = this.props;
    return (
      <View>
        <Text>Counter:{counter}</Text>

        <Button
          onPress={decrease}
        >
        <Text>Count--</Text>
        </Button>
        <Text>HomeScene</Text>

        <Button
          onPress={() => {
            Actions.details({ id: 123, otherParams: 'other params' });
          }}
        >
          <Text>详情页</Text>
        </Button>
      </View>
    );
  }
}


export default connect(
  mapStateToProps,
  { increase, decrease, fetchList,addToCart }
)(HomeScene);